
#ifndef XP_RATE_H
#define XP_RATE_H

#include "ScriptMgr.h"
#include "Common.h"
#include "PlayerGift.h"

#define KKK_MODULE_ENABLE_KEY "KkkGiftModule.Enable"


class XpRateEntry
{
    private:
        uint64 playerId;
        uint32 rate; // percentage value. 200 is for "double"
        uint32 hours;
        bool enabled;
    
    public:
        XpRateEntry(){}

        XpRateEntry(uint64 playerId, uint32 rate,uint32 hours,bool enable)
        {
            this->playerId = playerId;
            this->rate = rate;
            this->hours = hours;
            this->enabled = enable;
        }
        uint64 getPlayerId(){ return this->playerId;}
        uint32 getRate(){ return this->rate;}
        bool isEnabled() { return this->enabled;}
        void setRate(uint32 rate) { this->rate = rate; }
        void setHours(uint32 hours){ this->hours = hours; }
        void setEnable(bool enable){ this->enabled = enable;}
        void setPlayerId(uint64 playerId){
            this->playerId = playerId;
        }
};


class XpRate 
{

private:
    map<uint64 /* character's guid */,XpRateEntry* /*xp rate */> xpRateMap;
    void storeXpRateToDb(Player *p, uint32 rate, uint32 hours, bool enabled);
    XpRateEntry* getXpRateFromDb(Player *p);

public:
    XpRate(){}
    uint32 getXpRate(Player *p);
    void setXpRate(uint64 setterGuid /*nullable*/,uint64 targetGuid /* not null*/, uint32 rate, uint32 hours, bool enabled);
    void init();
    void refreshXpRate(Player *target);//从数据获取数据，并刷新内存中的任务经验倍率

};

#endif

